# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
#   include csns::cluster
class csns::cluster {
yumrepo { "site":
    baseurl => "http://${mirrorserver}/yum/site/${facts['os']['release']['major']}/\$basearch",
    descr => "site",
    enabled => 1,
    gpgcheck => 0,
    priority => $sitepriority,
  }
  package {["xrootd-client","xrootd-fuse"]:
    ensure  => "installed",
    require => Yumrepo['site']
  }

package {['kernel','kernel-headers','kernel-devel',]:
	ensure => "5.14.0-427.31.1.el9_4",
	require => Yumrepo['site']
}

 $clusterpkg = ['openmpi-devel','bash-completion','python2.7','vim-enhanced','glibc-langpack-en','rsync','wget','bc','python3-tkinter','libX11-devel','tk-devel','libstdc++-devel','gcc-c++','python3-devel','scalapack-openmpi-devel','lapack-devel','git','cmake','emacs','perl-English','hdf5-devel','libjpeg-devel','expat-devel','xerces-c-devel','tigervnc-server','tigervnc','xcb-util-renderutil-devel','libnsl','xcb-util-wm-devel','xcb-util-devel','xcb-util-cursor-devel','xcb-util-image-devel','xcb-util-keysyms-devel','xcb-util-xrm-devel','libxkbcommon-devel','libxkbcommon-x11-devel','chkconfig','gsl-devel','gnuplot','python-unversioned-command',]
  package { $clusterpkg:
    ensure  => "installed",
    require => Yumrepo['site']
  }

service {'puppet':
	ensure => "running",
	enable => "true",
}

service { 'firewalld':  
  ensure    => stopped,  
  enable    => false,  
  hasstatus => true,  
}


 file { '/etc/selinux/config':
    ensure => present,
  }

  # 修改SELinux配置文件
  file_line { 'disable_selinux':
         path  => '/etc/selinux/config',
         line  => 'SELINUX=disabled',
         match => '^SELINUX=',
  }
  
  # 立即设置SELinux为permissive模式(无需重启)
  exec { 'set_selinux_permissive':
        command => '/usr/sbin/setenforce 0',
        onlyif  => '/usr/sbin/getenforce | grep -i enforcing',
  }




#  yumgroup { 'Server with GUI':
#  ensure   => 'present',
# require => Yumrepo['site']
# } 

   file{'/etc/profile.d/dghpcDir.sh':
	source => "puppet://$puppetserver/modules/${module_name}/profile.d/dghpcDir.sh",
#	source => "puppet://$puppetserver/modules/${module_name}/slurm/slurmdbd.conf",
#	ensure => absent,
	ensure => present,
	owner => 'root',
	group => 'root',
 	mode => '0644',
       }

   file{'/etc/ld.so.conf.d/zidingyi.conf':
	source => "puppet://$puppetserver/modules/${module_name}/zidingyi/zidingyi.conf",
	ensure => present,
	owner => 'root',
	group => 'root',
 	mode => '0644',
	}

    
   file{'/usr/lib64/zidingyi':
#	source => "puppet://$puppetserver/modules/${module_name}/zidingyi/zidingyi.conf",
	ensure => directory,
	owner => 'root',
	group => 'root',
 	mode => '0755',
	}

   file{'/usr/lib64/zidingyi/libnsl.so.1':
	source => "puppet://$puppetserver/modules/${module_name}/zidingyi/libnsl.so.1",
	ensure => present,
	owner => 'root',
	group => 'root',
 	mode => '0755',
        require => File['/usr/lib64/zidingyi'],
	notify => Exec['ldconfig'],
	}

   exec{'ldconfig':
	command => 'sudo /sbin/ldconfig',  
	path    => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],  
	}


file { '/usr/local/vnc':
	ensure => link,
        target => '/hpcfs/slurm1_share/vnc',
        force => true, 
}

  if $facts['architecture'] == 'x86_64' {
  # 在 64 位主机上执行的操作
    file{'/etc/profile.d/queryHomequota.sh':
	source => "puppet://$puppetserver/modules/${module_name}/profile.d/queryHomequota.sh.x86",
#       source => "puppet://$puppetserver/modules/${module_name}/slurm/slurmdbd.conf",
        ensure => present,
        owner => 'root',
        group => 'root',
        mode => '0644',                                  
	}
  } 

  if $facts['architecture'] == 'aarch64' {
  # 在 64 位主机上执行的操作
    file{'/etc/profile.d/queryHomequota.sh':
	source => "puppet://$puppetserver/modules/${module_name}/profile.d/queryHomequota.sh.arm",
#       source => "puppet://$puppetserver/modules/${module_name}/slurm/slurmdbd.conf",
        ensure => present,
        owner => 'root',
        group => 'root',
        mode => '0644',                                  
	}
  } 
}
